package personal.xjl._23java1studentdemo.spring;


import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.aop.AfterReturningAdvice;
import org.springframework.aop.MethodBeforeAdvice;
import org.springframework.stereotype.Component;

import java.lang.reflect.Method;

@Component("myAdvice")
@Aspect
public class MyAdvice {
    @Before("execution(* personal.xjl._23java1studentdemo.spring.Cow.run())")
    public void before(){
        System.out.println("-------before advice-------");
    }
    @After("execution(* personal.xjl._23java1studentdemo.spring.OxCart.run())")
    public void afterReturning(){
        System.out.println("-------after advice-------");
    }
//    @Override
//    public Object invoke(MethodInvocation invocation) throws Throwable {
//        System.out.println("-------invoke advice-------");
//        Object returnValue = invocation.proceed();
//        System.out.println("-------invoke advice over-------");
//        return returnValue;
//    }
}
